<template>
	<view class="padding">
		<comment-list :list.sync="list" :videoId="id" />
	</view>
</template>

<script>
	import CommentList from '@/pages/video/components/CommentList'
	export default{
		data(){
			return {
				list:[],
				id:""
			}
		},
		components:{
			CommentList
		},
		methods:{
			async getCommentList(id) {
				let query = {
					id
				}
				let {
					data
				} = await this.$h.api.videoModel.getComment(query)
				this.list=data.comments.map(item => ({
					...item,
					isShowMore: false
				}))
			},
		},
		async onLoad({id}){
			this.id=id
			this.getCommentList(id)
			uni.$on('updateComment', async () => {
				this.getCommentList(id)
			})
		},
		beforeDestroy() {
			uni.$off("updateComment")
		},
	}
</script>

<style>
	page{
		background-color: #fff;
	}
</style>
